﻿using System;
using System.Collections.Generic;
using System.Xml;
using Autodesk.Revit.DB;
using YArchitech.LIB;

namespace YArchitech.HVAC.AuxiliaryCurve
{
	public class AuxiliaryCurveIdsSave
	{
		public AuxiliaryCurveIdsSave(ICollection<ElementId> idArgu)
		{
			this.Ids = idArgu;
			this.alGUID = "boostLineInfo";
		}

		public void SaveElementIds()
		{
			try
			{
				XmlDocument xmlDocument = new XmlDocument();
				xmlDocument.Load(this.pathName);
				foreach (ElementId elementId in this.Ids)
				{
					XmlNode xmlNode = xmlDocument.SelectSingleNode("ListDetailLine");
					XmlElement xmlElement = xmlDocument.CreateElement("DetailLine");
					xmlElement.InnerText = elementId.ToString();
					xmlElement.SetAttribute("dlType", this.alGUID);
					xmlNode.AppendChild(xmlElement);
				}
				xmlDocument.Save(this.pathName);
			}
			catch (Exception)
			{
				throw;
			}
		}

		private string pathName = Product.InstallLocation + "\\Data\\HYSprinklerCheck.XML";

		private string alGUID;

		private ICollection<ElementId> Ids;
	}
}
